package ltd.ninefish.framework.systemapi.factory;

import ltd.ninefish.framework.core.result.Result;
import ltd.ninefish.framework.systemapi.dto.SysLoginInfoDto;
import ltd.ninefish.framework.systemapi.dto.SysOperLogDto;
import ltd.ninefish.framework.systemapi.service.RemoteLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author zhaoxiubin
 * create-time 2024-01-16 8:32
 * description RemoteLogFallbackFactory
 **/
@Component
public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);

    @Override
    public RemoteLogService create(Throwable cause) {
        log.error("日志服务调用失败:{}", cause.getMessage());
        return new RemoteLogService()

        {
            @Override
            public Result<Boolean> saveLog(SysOperLogDto sysOperLog, String source)
            {
                return null;
            }

            @Override
            public Result<Boolean> saveLoginInfo(SysLoginInfoDto sysLoginInfo, String source)
            {
                return null;
            }
        };
    }
}
